import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserService } from './services/user.service';
import { ConfigureModule } from './configure/configure.module';
import { DatabaseModule } from './database/database.module';
import { Log4jsModule } from "@quickts/nestjs-log4js";
import { UserController } from './controllers/user.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserEntity } from './entities/user.entity';
import { configure } from 'configure/configure.module';
import { NewsEntity } from './entities/news.entity';
import { ProblemSummaryEntity } from './entities/problem-summary.entity';
import { Problem } from './entities/problem.entity';
import { RegulationEntity } from './entities/regulation.entity';
import { AuthController } from './controllers/auth.controller';
import { JwtModule } from '@nestjs/jwt';

@Module({
  imports: [
    ConfigureModule.forRoot(),
    DatabaseModule.forRoot(),
    Log4jsModule.forRoot(),
    TypeOrmModule.forRoot(configure.database),
    TypeOrmModule.forFeature([
      UserEntity,
      NewsEntity,
      ProblemSummaryEntity,
      Problem,
      RegulationEntity
    ]),
    JwtModule.register({
      secret: configure.passwordSalt,
      signOptions: { expiresIn: '8h' },
    }),
  ],
  controllers: [
    AppController,
    UserController,
    AuthController
  ],
  providers: [
    AppService,
    // UserService,
    {
      provide: UserService,
      useClass: UserService,
    }
  ],
})
export class AppModule {}
